import request from '../../../../../public/js/common/api/api.js';

const AuditUrl = Utils.CurDomain.AuditUrl;
const AccountUrl = Utils.CurDomain.AccountUrl;

const _ajaxOptions = {
    contentType: 'application/json',
    dataType: 'json',
    async: true,
    dataFilter(data, type) {
        return data;
    },
};

const configajaxOptions = {
    contentType: 'application/json',
    dataType: 'text',
    async: true,
    dataFilter(data, type) {
        return data;
    },
};

export default class InboundPlanApi {
    /**
     * 入厂计划 新增
     * @param id
     * @returns
     */
    static addEntryplans(data) {
        return request.post(`${AuditUrl}/entryplans`, data, { isLoading: true, text: '数据请求中..', _ajaxOptions, disTooltips: false });
    }

    /**
     * 入厂计划 修改
     * @param id
     * @returns
     */
    static editEntryplans(id, data) {
        return request.put(`${AuditUrl}/entryplans/${id}`, data, { isLoading: true, text: '数据请求中..', _ajaxOptions, disTooltips: false });
    }

    /**
     * 获取入厂计划人员入厂列表
     * @param id
     * @returns
     */
    static getDtInboundPlanList(data) {
        return request.post(`${AuditUrl}/entryplans/h5`, data, { isLoading: true, text: '数据请求中..', _ajaxOptions, disTooltips: false });
    }

    /**
     * 入厂计划查询人员入厂是否允许
     * @param id
     * @returns
     */
    static postVisible(data) {
        return request.post(`${AuditUrl}/entryplans/visible`, data, { isLoading: true, text: '校验中...', ajaxOptions: configajaxOptions, disTooltips: true });
    }

    /**
     * 入厂计划 详情
     * @param id
     * @returns
     */
    static getDetailPerInPlan(id) {
        return request.get(`${AuditUrl}/entryplans/${id}`);
    }
    /**
     * 入厂计划 签到
     * @param id
     * @returns
     */
    static checkinEntryplans(data) {
        return request.post(`${AuditUrl}/entryplans/checkin`, data, { isLoading: true, text: '数据请求中..', _ajaxOptions, disTooltips: false });
    }
    /**
     * 入厂计划 提交
     * @param ids
     * @returns
     */
    static submitInboundPlan(ids) {
        return request.put(`${AuditUrl}/entryplans/submit`, { ids: ids }, { isLoading: true, text: '数据请求中..', _ajaxOptions, disTooltips: false });
    }

    /**
     * 入厂计划 反提交
     * @param ids
     * @returns
     */
    static rollSubmitInboundPlan(ids) {
        return request.put(`${AuditUrl}/entryplans/unsubmit`, { ids: ids }, { isLoading: true, text: '数据请求中..', _ajaxOptions, disTooltips: false });
    }

    /**
     * 入厂计划 审核
     * @param ids
     * @returns
     */
    static auditInboundPlan(ids) {
        return request.put(`${AuditUrl}/entryplans/audit`, { ids: ids }, { isLoading: true, text: '数据请求中..', _ajaxOptions, disTooltips: false });
    }

    /**
     * 入厂计划 反审核
     * @param ids
     * @returns
     */
    static rollAuditInboundPlan(ids) {
        return request.put(`${AuditUrl}/entryplans/unaudit`, { ids: ids }, { isLoading: true, text: '数据请求中..', _ajaxOptions, disTooltips: false });
    }

    /**
     * 入厂计划  删除
     * @param id
     * @returns
     */
    static delEntryplans(id, data) {
        return request.delete(`${AuditUrl}/entryplans/${id}`, data, { isLoading: true, text: '数据请求中..', _ajaxOptions, disTooltips: false });
    }

    //获取公司和部门 aotype=10公司，aotype=1部门
    static queryBaseOrgunitList(upoid, aotype, taginfo) {
        return request.get(`${Utils.CurDomain.SysPlfUrl}/yyorgunits/by/q?upoid=${upoid}&aotype=${aotype}&taginfo=${taginfo}`);
    }

    //获取系统参数 获取猪厂
    static getSubdata(id) {
        return request.get(`${Utils.CurDomain.SubDataUrl}/prmtsettings/${id}/value`);
    }

    /**
     *获取参数设置的值
     * @param {*} data
     * @returns
     */
    static getPrmtSettings(id) {
        return request.get(`${Utils.CurDomain.SubDataUrl}/prmtsettings/${id}/value`);
    }

    /**
     * 微信公众号 JS-SDK 权限验证签名
     * @param id
     * @returns
     */
    static getjssdksign(sid, url) {
        return request.get(`${Utils.CurDomain.WeiXinUrl}/wxauths/jssdksign?sid=${sid}&url=${url}`);
    }

    /**
     * 获取入厂计划其他车辆入厂列表
     * @param id
     * @returns
     */
    static othercarplanlist(data) {
        return request.post(`${AuditUrl}/entryplans/h5/othercar`, data, { isLoading: true, text: '数据请求中..', _ajaxOptions, disTooltips: false });
    }

    //TODO :获取用户关联员工信息
    static queryUserInfo() {
        return request.get(`${AccountUrl}/accounts/eply`);
    }
}
